<template>
  <div class="core">
    <div class="content">
      <div class="comment">
        <div class="desc">评论内容：</div>
        <Input type="text" v-model="info.content" style="width: 300px"></Input>
      </div>

      <div class="reply">
        <div class="desc">回复者名称：</div>
        <Input
          type="text"
          v-model="info.replyNickname"
          style="width: 300px"
        ></Input>
      </div>
      <div class="comment">
        <div class="desc">评论:显示/隐藏</div>
        <RadioGroup v-model="info.commentStatus">
          <Radio :label="0">显示</Radio>
          <Radio :label="1">不显示</Radio>
        </RadioGroup>
      </div>
      <!-- <div class="reply">
        <div class="desc">评论时间：</div>
        <DatePicker
        style="width: 200px; margin-right: 40px"
        type="date"
        placeholder="评论时间"
        @on-change="changeDate"
        format="yyyy-MM-dd HH:mm:ss"
        model-value="yyyy-MM-dd"
        v-model="info.created"
      ></DatePicker>

      </div> -->
      <div class="footer">
        <Button
          type="primary"
          size="default"
          style="margin-right: 140px"
          @click="returnPage"
          >返回</Button
        >
        <Button type="primary" size="default" @click="editData">确定</Button>
      </div>
    </div>
  </div>
</template>

<script>
import { edidfindById, editcomments } from "@/base/api/Moments";
export default {
  data() {
    return {
      info: "",

    };
  },
  methods: {
    getEditData() {
      edidfindById(this.$route.query.id).then((res) => {
        this.info = res.data;
        this.info.commentStatus = this.commentStatus
      });
    },
    changeDate(date) {
      console.log(date);
      this.info.created = date;
    },
    returnPage() {
      this.$router.push({
        path:"/commentmanagement",
        query:{
            momentId:this.$route.query.momentId,
            title:this.$route.query.title
        }
      });
    },
    editData() {
      editcomments(this.info).then((res) => {
        this.$message.success("修改成功");
        this.$router.push({
        path:"/commentmanagement",
        query:{
            momentId:this.$route.query.momentId,
            title:this.$route.query.title
        }
      });
      });
    },
  },
  mounted() {
    this.getEditData();
    this.commentStatus = Number(this.$route.query.commentStatus)
  },
};
</script>

<style lang="less" scoped>
.core {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  .content {
    .comment {
      display: flex;
      align-items: center;
      margin-top: 20px;
      .desc {
        width: 120px;
      }
    }
    .reply {
      display: flex;
      align-items: center;
      margin-top: 20px;
      .desc {
        width: 120px;
      }
    }
    .footer {
      margin-top: 40px;
    }
  }
}
</style>
